package cn.tedu.csmall.pageinfo.controller;

import cn.tedu.csmall.commons.pojo.order.model.Order;
import cn.tedu.csmall.commons.restful.JsonResult;
import cn.tedu.csmall.pageinfo.service.IOrderService;
import cn.tedu.csmall.pageinfo.service.impl.OrderServiceImpl;
import com.github.pagehelper.PageInfo;
import com.sun.org.apache.xpath.internal.operations.Or;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order/pageinfo")
@Api(tags = "订单分页")
public class OrderController {
    @Autowired
    private IOrderService orderService;

    @GetMapping("/page")
    @ApiOperation("分页查询所有订单")
    @ApiImplicitParams({@ApiImplicitParam(value = "页码", name = "pageNum", required = true, dataType = "int"),
            @ApiImplicitParam(value = "每页条数", name = "pageSize", required = true, dataType = "int")
    })
    public JsonResult<PageInfo<Order>> listOrderByPage(Integer pageNum, Integer pageSize){
        PageInfo<Order> pageInfo = ((OrderServiceImpl)orderService).getAllOrdersByPage(pageNum, pageSize);
        return JsonResult.ok("查询完成", pageInfo);
    }
}
